const path = require('path');
const htmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
	entry: path.join(__dirname, './src/main.js'),
	output: {
		path: path.join(__dirname, './dist'),
		filename: 'bundle.js'
	},
	plugins: [
		new htmlWebpackPlugin({
			template: path.join(__dirname, './src/index.html'),
			filename: 'index.html'
		})
	],
	module: {
		rules: [
			// 处理css文件
			{test: /\.css$/, use: ['style-loader', 'css-loader']},
			// 处理less文件
			{test: /\.less/, use: ['style-loader', 'css-loader', 'less-loader']},
			// 处理scss文件
			{test: /\.scss/, use: ['style-loader', 'css-loader', 'sass-loader']},
			//处理图片
			{test: /\.(jpg|png|gif|bmp|jpeg)$/, use: 'url-loader'},
			// 处理字体文件
			{test: /\.(ttf|eot|svg|woff|woff2)$/, use: 'url-loader'},
			// 配置babel吃力es6高级语法
			{ test: /\.js$/, use: 'babel-loader', exclude: /node_modules/ },
			// 处理vue文件
			{test: /\.vue$/, use: 'vue-loader'}
		]
	}
}